<template>
<div>
  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <span>yrx</span>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu>
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-message"></i>导航一</template>
            <el-menu-item index="1-1">选项1</el-menu-item>
            <el-menu-item index="1-2">选项2</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>导航二</template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <table border="1" align="center"  class="custom-table">
            <tr>
              <td>编号</td>
              <td>姓名</td>
              <td>年龄</td>
              <td>性别</td>
              <td>分数</td>
              <td>生日</td>
              <td>班级</td>
            </tr>
            <tr v-for="stu in StudentList">
              <td>{{stu.id}}</td>
              <td>{{stu.sname}}</td>
              <td>{{stu.age}}</td>
              <td>{{stu.sex}}</td>
              <td>{{stu.score}}</td>
              <td>{{stu.birthday}}</td>
              <td>{{stu.cid}}</td>
            </tr>
          </table>
        </el-main>
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </el-container>
</div>
</template>

<script>
import axios from "axios";
export default {
  name: "Admin",
  data() {
    return {
      StudentList:[]
    }
  },
  methods: {
    fetchData(){
      axios.get("/stu/list")
          .then(res=>{

            console.log(res.data)
            //const R=res.data;
            this.StudentList=res.data
          })
          .catch(function (error){
            console.log(error)
          })
    }
  },
  created() {
    this.fetchData()
  }
}
</script>

<style scoped>
.el-header, .el-footer {
  background-color: #22819d;
  color: #333;
  text-align: center;
  line-height: 55px;
}

.el-aside {
  background-color: #274767;
  color: white;
  text-align: center;
  line-height: 200px;
  height: 545px;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 100px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.custom-table td {
  height: 100px; /* 减小行高 */
  padding: 5px; /* 减小内边距 */
  text-align: center;
  border: 1px solid #ccc;
}

.custom-table tr:first-child td {
  background-color: #f5f5f5;
  font-weight: bold;
}

</style>